import { useRoute } from "vue-router";
import { useDetail, useList } from "@/hooks";
import { ref } from "vue";
import { getUserInfoUrl } from "@/command/apiTool";
import { getAction } from "@/command/netTool";
import * as vant from "vant";
const { showFailToast, showSuccessToast } = vant;
export const useRequest = () => {
  const route = useRoute();
  // 申请列表-大户查看小户申请帮工列表-大户
  const [workList, workListControl] = useDetail(
    getUserInfoUrl(
      {
        dh: "/api/H5/service/helpWork/heavy/getApplyWorkList",
        xh: "",
      },
      {
        workId: route.query.id,
      }
    ),
    {
      title: "",
      workName: "",
      workDay: "",
      workPrice: "",
      userApplyVOList: [],
    }
  );

  // 按钮操作
  const btnAction = (params: any) => {
    let queryParams = {
      ...params,
      workId: route.query.id,
    };
    getAction(
      "/api/H5/service/helpWork/heavy/agreeOrReject",
      { ...queryParams },
      { isResolve: true }
    ).then((e) => {
      showSuccessToast(e.data);
      // 刷新接口
      workListControl.refresh();
    });
  };
  return {
    workList,
    btnAction,
  };
};
